package com.fh.controller;


import com.fh.model.ProductSearch;
import com.fh.model.Products;
import com.fh.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import utils.ResultObj;

@RestController
@CrossOrigin
@RequestMapping("search")
public class SearchController {

    @Autowired
    private SearchService searchService;
    @GetMapping
    public ResultObj getProductByKey(Products products){
        return ResultObj.success(searchService.getProductByKey(products));

    }
    @GetMapping("{productId}")
    public ResultObj getProductDetail(@PathVariable("productId") String productId){
        ProductSearch productSearch = searchService.getProductDetail(productId);
        return ResultObj.success(productSearch);

    }

}

